package klok;

import javax.swing.*;

import java.awt.GridLayout;
import java.awt.event.*;
import java.util.ArrayList;
import java.util.Observable;
import java.util.Observer;
import java.util.Scanner;

public class KlokFrame extends JFrame implements Observer {
	private KlokPanel klok;
	private static final int height = (int)(KlokPanel.KLOKSTRAAL *2.5);
	private int[] time;
	private int[] alarm;

	public KlokFrame() {
		super("klokje");
		time = new int[] { 0, 0, 0 };
		alarm = new int[] { 0, 0, time[2] + 5 };
		createClock();
		setSize((KlokPanel.KLOKSTRAAL *2), height);
		this.setResizable(false);
		addWindowListener(new FrameAfsluiter());

	}

	private class FrameAfsluiter extends WindowAdapter {
		public void windowClosing(WindowEvent e) {
		}
	}

	private void createClock() {
		klok = new KlokPanel(time);
		klok.setAlarmTimer(alarm);
		getContentPane().add(klok);
	}

	public void createFrame() {
		this.setVisible(true);
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}

	@Override
	public void update(Observable o, Object arg) {
		klok.update();
	}

}